# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_realname=highlight
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=4.8
pkgrel=1
url="http://www.andre-simon.de/doku/highlight/highlight.html"
pkgdesc="Fast and flexible source code highlighter (CLI version) (mingw-w64)"
license=('spdx:GPL-3.0-or-later')
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-lua")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-boost")
source=("https://gitlab.com/saalen/highlight/-/archive/v${pkgver}/highlight-v${pkgver}.tar.bz2"
        "001-fix-installation-prefix-and-destdir.patch"
        "002-fix-data-dir-stat.patch")
sha256sums=('1d152e47aabd497e0f92faeea42bf6dc6ceb53a31ece50fab1555f25676d8844'
            '13bfb4f326bd890c14c70c0fb30fc1d9ca7a0a8f0712f1c5e946bb59b942f3bb'
            'c371d1d2b98d364eedcfd7e2dfec1359bdcdeb73d7521331fa28c00623b4b9e2')

prepare() {
  cd "$srcdir/${_realname}-v${pkgver}/"
  patch -p1 -i "${srcdir}"/001-fix-installation-prefix-and-destdir.patch
  patch -p1 -i "${srcdir}"/002-fix-data-dir-stat.patch
}

build() {
  cp -r "$srcdir/${_realname}-v${pkgver}/" "${srcdir}"/build-${MSYSTEM}
  cd "${srcdir}"/build-${MSYSTEM}

  make PREFIX=${MINGW_PREFIX} CXX_DIR=
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}
  DESTDIR="${pkgdir}" PREFIX=${MINGW_PREFIX} make install
}
